//
//  String+category.swift
//  swift-GWYWeiBo
//
//  Created by x on 2017/4/1.
//  Copyright © 2017年 HLB. All rights reserved.
//

import UIKit
//String的分类
extension String{
    
    
    /// 将当前字符串拼接到caches目录下
    ///
    /// - Returns: <#return value description#>
    func cacheDir() -> String {
        let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last! as NSString //转换成oc中字符串
        return path.appendingPathComponent((self as NSString).lastPathComponent)
        
    }
    
    /// 将当前字符串凭借到docDir目录下
    ///
    /// - Returns: <#return value description#>
    func docDir() -> String {
        let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).last! as NSString //转换成oc中字符串
        return path.appendingPathComponent((self as NSString).lastPathComponent)
    }
    
    /// 讲当前字符串拼接到tem目录下
    ///
    /// - Returns: <#return value description#>
    func tempDir() -> String {
        let path = NSTemporaryDirectory() as NSString
        return path.appendingPathComponent((self as NSString).lastPathComponent)
    }
}
